package logic

import (
	"common/model"
	"context"
	"errors"
	product "product_server/proto"
)

func (p *ProductServer) ProductInfo(ctx context.Context, req *product.ProductInfoRequest) (*product.ProductInfoResponse, error) {
	info, err := model.GetProductInfo(req.Id)
	if err != nil {
		return nil, errors.New("商品不存在")
	}

	return &product.ProductInfoResponse{
		Id:        info.Id,
		CateId:    info.CateId,
		StoreName: info.StoreName,
		Browse:    info.Browse,
		Sales:     info.Sales,
		Collect:   info.Collect,
		StoreInfo: info.StoreInfo,
		Image:     info.Image,
		Price:     info.Price,
	}, nil
}
